#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

import time
from gevent import monkey, spawn, joinall

monkey.patch_all()


def task(*args):
    time.sleep(0.4)
    print(*args)


def sync():
    for i in range(100):
        task(i)


def asy():
    g_list = [spawn(task, i) for i in range(100)]
    joinall(g_list)

start = time.time()
# sync()                  # 执行时长: 40.13500428199768
asy()                 # 执行时长  0.43876171112060547
stop = time.time()
print("执行时长: {}".format(stop-start))
